﻿@if (Model.Staffs != null && Model.Staffs.Count != 0)
{
    <CnGalWebSite.Components.Containers.MasaTitleContainer Title="Staff" Icon="@IconType.Staff.ToIconString()" Collapable>
        <ButtonContent>
            <CnGalWebSite.Components.Buttons.MasaButton Fab XSmall Icon="@IconType.Export.ToIconString()" Tooltip="导出STAFF" OnClick="OnExport" StopPropagation Class="me-4" />
        </ButtonContent>
        <ChildContent>
            <div>
                @{ int index = 0;}
                @foreach (var item in Model.Staffs)
                {
                    <div class="@(Model.Staffs.IndexOf(item)<Model.Staffs.Count-1?"mb-2":"")">
                        @if (string.IsNullOrWhiteSpace(item.Modifier) == false)
                        {

                            <h3 class="fw-bold ma-1 h6 @ColorExtensions.GetGradientColor(index,true)">
                                @item.Modifier
                            </h3>
                            index++;
                        }

                        @foreach (var infor in item.StaffList)
                        {
                            <div style=" display: flex; flex-wrap: wrap; ">
                                <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.OutlineButton IsTitile="true" Text="@infor.Modifier" Color="@ColorExtensions.GetGradientColor(index)" />

                                @foreach (var temp in infor.Names)
                                {
                                    <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.OutlineButton IsTitile="false" Text="@temp.DisplayName" IsShowExistTag="Model.IsEdit" EntryId="@temp.Id" Color="@ColorExtensions.GetGradientColor(index)" />
                                }
                            </div>
                            index++;
                        }
                    </div>
                
                }

            </div>
        </ChildContent>
    </CnGalWebSite.Components.Containers.MasaTitleContainer>
}
@if (export)
{
    <MDialog @bind-Value="export"
             MaxWidth="500">
        <MDCard>
            <MCardTitle Class="text-h5">
                导出STAFF
            </MCardTitle>
            <MCardText>
                <PCopyableText Style=" white-space: pre-line!important; display: flex; flex-direction: column; align-items: flex-start;">
                    @Model.Staffs.Export()
                </PCopyableText>
             
            </MCardText>
        </MDCard>
    </MDialog>
}
@code {
    [Parameter]
    public EntryIndexViewModel Model { get; set; }
    bool export;

    public string GetColor(int index, bool isText = false)
    {
        return ColorExtensions.GetGradientColor(index, isText);
    }

    public void OnExport()
    {
        export = true;
        StateHasChanged();
        
    }
}
